API Documentation
Matrix.h
1 // Matrix.h
3 //
5 
6 namespace nkMaths
7 {
13  class Matrix : public ByteAlignedClass<16>
14  {
15  public :
16 
17  float _m [4][4] ;
18 
19  public :
20 
25  Matrix () ;
37  Matrix (float m00, float m01, float m10, float m11) ;
54  Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) ;
77  Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) ;
83  Matrix (const Matrix& other) ;
87  ~Matrix () ;
88 
89  // Getters
93  Vector getRow0 () const ;
97  Vector getRow1 () const ;
101  Vector getRow2 () const ;
105  Vector getRow3 () const ;
109  Vector getCol0 () const ;
113  Vector getCol1 () const ;
117  Vector getCol2 () const ;
121  Vector getCol3 () const ;
130  float get (unsigned int row, unsigned int col) const ;
131 
132  // Setters
141  void set (float val, unsigned int row, unsigned int col) ;
142 
143  // Alterations
159  Matrix getTranspose () const ;
184 
185  // Transformations
211  void getDecomposed (Vector& position, Quaternion& orientation, Vector& scale) ;
212 
220  void setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
232  void setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
244  void setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
250  void setPositionComponent (const Vector& position) ;
262  void setScaleComponent (const Vector& scale) ;
270  void setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
271 
272  // Utilities
276  float getDeterminantMat2 () const ;
280  float getDeterminantMat3 () const ;
284  float getDeterminantMat4 () const ;
288  float getTraceMat3 () const ;
292  float getTraceMat3 () const ;
296  float getTraceMat4 () const ;
297 
304  void fromString (const std::string_view& str) ;
305 
306  // Operators
313  Matrix& operator= (const Matrix& other) ;
320  bool operator== (const Matrix& other) ;
327  bool operator!= (const Matrix& other) ;
334  Matrix operator+ (const Matrix& other) const ;
340  void operator+= (const Matrix& other) ;
347  Matrix operator- (const Matrix& other) const ;
353  void operator-= (const Matrix& other) ;
360  Matrix operator* (const Matrix& other) const ;
367  Vector operator* (const Vector& toApply) const ;
374  Matrix operator* (float scalar) const ;
380  void operator*= (const Matrix& other) ;
386  void operator*= (float scalar) ;
393  Matrix operator/ (float scalar) const ;
399  void operator /= (float scalar) ;
400  } ;
401 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::~Matrix
~Matrix()
nkMaths::Matrix::operator!=
bool operator!=(const Matrix &other)
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Quaternion &orientation, Vector &scale)
nkMaths::Matrix::setScaleComponent
void setScaleComponent(const Vector &scale)
nkMaths::Matrix::setPositionComponent
void setPositionComponent(const Vector &position)
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::operator*
Matrix operator*(const Matrix &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::setToTransformation
void setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::setToViewMatrixDirection
void setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::setToOrthographicMatrix
void setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix::_m
float _m[4][4]
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:17
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::operator-=
void operator-=(const Matrix &other)
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::Matrix
Matrix()
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::operator==
bool operator==(const Matrix &other)
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::operator/=
void operator/=(float scalar)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m10, float m11)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::set
void set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::operator+
Matrix operator+(const Matrix &other) const
nkMaths::Matrix::operator-
Matrix operator-(const Matrix &other) const
nkMaths::Matrix::setOrientationComponent
void setOrientationComponent(const Quaternion &rot)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::fromString
void fromString(const std::string_view &str)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::operator=
Matrix & operator=(const Matrix &other)
nkMaths::Matrix::Matrix
Matrix(const Matrix &other)
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Matrix::operator*=
void operator*=(const Matrix &other)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::setToPerspectiveMatrix
void setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::operator/
Matrix operator/(float scalar) const
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMaths::Matrix::operator+=
void operator+=(const Matrix &other)